package com.ruoyi.system.service.news.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.ruoyi.system.domain.news.NewsImportantDynamic;
import com.ruoyi.system.domain.news.query.NewsImportantDynamicQuery;
import com.ruoyi.system.domain.news.vo.NewsImportantDynamicVo;
import com.ruoyi.system.domain.news.vo.NewsImportantDynamicVo;
import com.ruoyi.system.mapper.news.NewsImportantDynamicMapper;
import com.ruoyi.system.service.news.NewsImportantDynamicService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class NewsImportantDynamicServiceImpl extends ServiceImpl<NewsImportantDynamicMapper, NewsImportantDynamic>
        implements NewsImportantDynamicService {

    @Override
//    @DataScope(deptAlias = "t",userAlias = "t")
    public List<NewsImportantDynamicVo> getNewsImportantDynamicList(NewsImportantDynamicQuery newsImportantDynamicQuery) {
        if (newsImportantDynamicQuery.getIfPage()) {
            PageHelper.startPage(newsImportantDynamicQuery.getPageNum(), newsImportantDynamicQuery.getPageSize());
        }
        List<NewsImportantDynamicVo> newsImportantDynamicVoList = baseMapper.getNewsImportantDynamicList(newsImportantDynamicQuery);
        if (!newsImportantDynamicVoList.isEmpty() && newsImportantDynamicQuery.getId() == null) {
            for (NewsImportantDynamicVo newsImportantDynamicVo:newsImportantDynamicVoList) {
                newsImportantDynamicVo.setContent(null);
            }
        }
        return newsImportantDynamicVoList;
    }
}
